home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Format 1994 October
/
Macformat17.cdr
/
Shareware City
/
Developers
/
Think C dcmd 1.0 ƒ
/
Sample dcmd
/
dcmd.c
< prev
next >
Wrap
Text File
|
1994-06-18
|
1KB
|
74 lines
/*****************************************************
bin.c P. Stadelmann, June 1994
Displays a long word in binary.
*****************************************************/
#include <SetUpA4.h>
#include <Think_dcmd.h>
#include <Think_put.h>
void DoHelp( void )
{
PutClear();
PutPStr( "\pbin num");
PutLine();
PutPStr( "\p Displays the value in num as a binary long.");
PutLine();
}
void DoJob()
{
long value;
Boolean ok;
Str255 myStr;
short pos;
if ( dcmdPeekAtNextChar() == '\r' )
{
PutClear();
PutPStr( "\pValue not found" );
}
else
{
pos = dcmdGetPosition();
dcmdGetNextExpression( &value, &ok );
if (ok)
{
PutClear();
dcmdSetPosition( pos );
dcmdGetNextParameter( myStr );
PutPStr( myStr );
PutPStr( "\p = ");
PutBinary(value, 32);
}
else
PutPStr( "\pSyntax error");
}
PutLine();
}
pascal void CommandEntry( dcmdBlock* paramPtr )
{
RememberA0();
SetUpA4();
switch ( paramPtr->request )
{
case dcmdInit : break;
case dcmdHelp : DoHelp();
break;
case dcmdDoIt : DoJob();
break;
}
RestoreA4();
}